#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "gpio_op.h"

void buzzer_on() {
	GPIO_ResetBits(GPIOC, GPIO_Pin_1);
}

void buzzer_off() {
	GPIO_SetBits(GPIOC, GPIO_Pin_1);
}

void start_buzzer(uint32_t times, uint32_t work_time, uint32_t interval, uint32_t stop_time) {
	/*开启时钟*/
	//使用各个外设前必须开启时钟，否则对外设的操作无效
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
	
	gpio_init(GPIOC, GPIO_Pin_1);
	
	while (1) {
		for (uint32_t i = 0; i < times; i ++) {
			buzzer_on();
			Delay_ms(work_time);
			buzzer_off();
			Delay_ms(interval);
		}
		Delay_ms(stop_time);
	}
}
